/*
 * 作者: 张帆
 * 时间: 2017-05-05
 * 说明：
 * Copyright (c) 2016-2017 中研沃兮
 */
define(function(require) {
	
	require("jquery");

	var c = require('app/utils/CommonUtils');
	var APIUtils = require('app/utils/APIUtils');
	var appInfo = require('app/AppInfo');
	var action_search = require('app/action/SearchIconFrmAction');
	var UserInfoUtils = require('app/utils/UserInfoUtils');
	var hc=require('app/utils/HttpClientUtils');
	var EventUtils = require('app/utils/EventUtils');
	var param = api.pageParam;	

	$("#enroll").on("click",function(){
		var roomuuid=param.uuid;
		var url=appInfo.serverbase+'/luyan/form/room/' + roomuuid + '/enrollcheck/custom_2';
		var body={};
		var useruuid=UserInfoUtils.getLoginedUser().userid;
		
		body.useruuid=useruuid;
		body.name = $("#reserve_name").val();
		body.company = $("#reserve_company").val();
		body.position = $("#reserve_position").val();
		body.tel=$("#reserve_tel").val();
		body.useruuid = useruuid;
		
		if(c.isNullStr(body.name)){
			alert("姓名不能为空");
			return;
		}
		if(c.isNullStr(body.company)){
			alert("单位不能为空");
			return;
		}
		if(c.isNullStr(body.position)){
			alert("职务不能为空");
			return;
		}
		if(c.isNullStr(body.tel)){
			alert("手机号不能为空");
			return;
		}

		if(!c.isTel(body.tel)){
			alert("请正确输入11位手机号");
			return;
		}

		hc.post(url,body,function(resp){
			if(resp.status=="200"&&resp.result.next){
				api.closeFrame({
                });
				EventUtils.send('RoomWin','close_staging_frm');
				EventUtils.send('RoomWin','show_room');
			}else{
				alert('报名失败，请重试');
			}
		})
	})
	$(".aui-pull-left").click(function(){
		api.closeWin({
        });
	})
	return;
});